package cn.stronglink.assetmanage.business.check.view.checked;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import cn.stronglink.assetmanage.R;
import cn.stronglink.assetmanage.business.check.adapter.CheckListAdapter;
import cn.stronglink.assetmanage.business.check.adapter.CheckOrderAdapter;
import cn.stronglink.assetmanage.business.check.view.CheckFragment;
import cn.stronglink.assetmanage.business.check.view.detail.CheckedDetailFragment;
import cn.stronglink.assetmanage.business.check.view.wait.WaitAssetFragment;
import cn.stronglink.assetmanage.entity.Asset;
import cn.stronglink.assetmanage.entity.Check;
import cn.stronglink.assetmanage.utils.Constants;

/**
 * 操作入库界面
 * Created by chencongcong on 2018/6/12.
 */

public class CheckedAssetView {
    private Fragment fragment;
    //具体表单内容描述布局
    @BindView(R.id.ll_checked_list_content)
    LinearLayout ll_checked_list_content;
    //表单号
    @BindView(R.id.tv_checked_order_name)
    TextView tv_checked_order_name;
    //创建日期
    @BindView(R.id.tv_checked_operation_date)
    TextView tv_checked_operation_date;
    //某个表单的资源列表
    @BindView(R.id.rv_checked_in_list)
    RecyclerView rv_checked_in_list;
    //表单列表adapter
    private CheckListAdapter listAdapter;
    //资源列表adapter
    private CheckOrderAdapter orderAdapter;
    //执行日期
    @BindView(R.id.tv_checked_operation_date_1)
    TextView tv_checked_operation_date_1;

    public CheckedAssetView(Fragment fragment, View view, CheckOrderAdapter orderAdapter) {
        this.fragment = fragment;
        ButterKnife.bind(this, view);
        this.listAdapter = listAdapter;
        this.orderAdapter = orderAdapter;
    }


    /**
     * 设置表单列表数据
     *
     * @param listData 表单列表
     */
    public void setListData(List<Check> listData) {
        if (listAdapter != null) {
            listAdapter.notifyDatasChanged(listData);
        }
    }

    /**
     * 设置表单的资产列表数据
     *
     * @param orderData
     */
    public void setOrderData(List<Asset> orderData) {
        if (orderAdapter != null) {
            orderAdapter.notifyDatasChanged(orderData);
        }
    }

    /**
     * 显示入库资源列表表头
     */
    public void showAssetTitle(Check check) {
        if (check != null) {
            tv_checked_order_name.setText(check.getId_());
            tv_checked_operation_date.setText(check.getCreateTime());
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
            tv_checked_operation_date_1.setText(sdf.format(new Date()));
        }
    }


}
